using System;

namespace CSW.Framework.Common.Binding
{
    /// <summary>
    /// ComplexProperty&lt;T&gt;.  This class' main purpose is to act similar to an 
    /// interface with operator overloading and overriding certain methods. The operators
    /// are marked with the <see cref="ObsoleteAttribute" /> to give a warning to users
    /// that they should perform comparisons on the <see cref="Value" /> property.
    /// </summary>
    /// <typeparam name="T">The value type.</typeparam>
    public abstract class ComplexProperty<T> : ComplexProperty
    {
        /// <summary>
        /// Gets or sets the value.
        /// </summary>
        /// <value>The value.</value>
        public abstract T Value { set; get; }

        /// <summary>
        /// Gets the type of the value.
        /// </summary>
        /// <value>The type of the value.</value>
        public override Type ValueType
        {
            get { return typeof(T); }
        }

        /// <summary>
        /// Sets the value to default(T).
        /// </summary>
        public override void ClearValue()
        {
            Value = default(T);
        }

        /// <summary>
        /// Gets or sets the value.
        /// </summary>
        /// <value>The value.</value>
        public override object UnsafeValue
        {
            set { Value = (T)value; }
            get { return Value; }
        }

        /// <summary>
        /// Not implemented.
        /// </summary>
        [Obsolete("Use .Value on ComplexProperty", true)]
        public static bool operator ==(ComplexProperty<T> c1, ComplexProperty<T> c2)
        {
            throw new Exception("Use .Value on ComplexProperty.");
        }

        /// <summary>
        /// Not implemented.
        /// </summary>
        [Obsolete("Use .Value on ComplexProperty", true)]
        public static bool operator !=(ComplexProperty<T> c1, ComplexProperty<T> c2)
        {
            throw new Exception("Use .Value on ComplexProperty.");
        }

        /// <summary>
        /// Not implemented.
        /// </summary>
        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }

        /// <summary>
        /// Not implemented.
        /// </summary>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
